import time
import csv

from selenium import webdriver
from selenium.webdriver import ActionChains
from selenium.webdriver.common.by import By

wd = webdriver.Chrome()
wd.get("http://172.16.60.131:5700/")
wd.implicitly_wait(10)
wd.find_element_by_xpath("//input[@placeholder= '邮箱']").send_keys("admin@forensix.cn")

# 输入密码
wd.find_element_by_xpath("//input[@placeholder = '密码']").send_keys("a2ff9d42")

# 点击“授权并登录”按钮
wd.find_element_by_xpath("//span[text() = '登录']").click()

# 进入用户管理页面
wd.find_element(By.XPATH, '//a/div[text()="用户管理"]').click()




with open('user.csv', encoding='utf-8') as f:
    f_csv = csv.DictReader(f)
    for i in f_csv:
        name = i['name']
        email = i['email']
        passwd = i['passwd']
        wd.find_element(By.XPATH, '//span[text()="新增"]').click()
        wd.find_element(By.XPATH,'//form[@class="el-form"]/div//input[@class="el-input__inner"]').send_keys(name)
        wd.find_element(By.XPATH,'//form[@class="el-form"]/div[2]//input[@class="el-input__inner"]').send_keys(email)
        wd.find_element(By.XPATH,'//span[text()="是"]').click()
        wd.find_element(By.XPATH,'//form[@class="el-form"]/div[8]//input[@class="el-input__inner"]').send_keys(passwd)
        wd.find_element(By.XPATH,'//div[@aria-label="添加"]//button[@class="el-button el-button--primary"]').click()


wd.close()